<style>

.editPanel p label{
    width:130px;
    padding-left:15px;
    margin-right:5px;
    nowrap;
}

.pageFormContent .panel .panelContent{
    padding-right:6px;
}



</style>
<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet" type="text/css">
<form method="post" action="${rc.getContextPath()}/manage/workUnitType/saveWorkUnitType" class=" pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
    <div class="pageContent" >
        <div class="pageFormContent" >
            <input type="hidden" name="navTabId" value="${navTabId!''}">
            <input type="hidden" name="id"
                value="<#if (workUnitType.typeText)??>${workUnitType.typeText!''}</#if>">
                <div class="editPanel">
                <p>
                        <label ><@label key="workUnitTypeCode.C,colon">作业单元类型编号：</@label></label> <input class="required  alphanumeric toUp" name="workUnitTypeCode" value="<#if (workUnitType.workUnitTypeCode)??>${workUnitType.workUnitTypeCode!''}</#if>" size="20"
                            type="text" maxlength="20" warn="<@label key="workUnitTypeCodeExist.M">作业单元类型编号已经存在</@label>"
                        <#if (workUnitType.workUnitTypeCode)??> readonly="readonly"<#else> remote="${rc.getContextPath()}/manage/workUnitType/validateWorkUnitTypeCode"</#if> /> 
                </p>        
                <p>
                        <label ><@label key="workUnitTypeText.C,colon">作业单元类型描述：</@label></label> <input  name="typeText" value="<#if (workUnitType.typeText)??>${workUnitType.typeText!''}</#if>" size="20"
                            type="text" maxlength="60" 
                            <#if "read"==pattern>
                            readonly="readonly"
                            </#if>
                        />
                </p>
                <p>
                        <label>&nbsp;</label> 
                        <label>
                        <input type="checkbox" name="lockFlag" value="1"
                            <#if "read"==pattern>
                            disabled="disabled"
                            </#if>
                            <#if
                            (workUnitType.lockFlag)?? && (workUnitType.lockFlag == 1)>
                            checked="true"</#if> />
                        <@label key="lock.C">锁定</@label></label>
                </p>    
                
                </div>
                        <div class="panel" >
                            <h1><@label key="workUnit.C">作业单元</@label></h1>
                             <div class="panelContent">
                                    <#if "read"!=pattern>
                                    <div id="workUnitBar" class="pBar">
                                        <ul class="toolBar">
                                            <input id="workUnitCode"  type="hidden" name="workUnitLookup.workUnitCode" type="text" />
                                            <input id="workUnitText"  type="hidden" name="workUnitLookup.workUnitText" type="text" />
                                            <input id="workCenterCode" type="hidden" name="workUnitLookup.workCenterCode" type="text" />
                                            <li><a class="add"  width="750" height="350"  href="${rc.getContextPath()}/manage/workUnitType/selectWorkUnit?navTabId=${navTabId!''}"  rel="selectWorkUnit1" lookupGroup="workUnitLookup" callback="workUnit_callback" title="<@label key='addWorkUnit.D'>新增作业单元</@label>"><span>
                                            <@label key='add.B'>新增</@label></span> </a>
                                            </li>
                                            <li><a href="javascript:" class="delete" onclick="workUnitdel()"><span><@label key="delete.B">删除</@label></span> </a>
                                            </li>
                                        </ul>
                                    </div>
                                    </#if>
                            
                                    <table id="workUnitTypeTable" class="table border canopration" width="100%"  <#if "add"==pattern>layoutH="260"<#else>layoutH="330"</#if>>
                                        <thead>
                                            <tr>
                                                <th width="20"><input type="checkbox" group="ids" class="checkboxCtrl">
                                                </th>
                                                <th width="100"><@label key="workUnitCode.C">作业单元编号</@label></th>
                                                <th width="100"><@label key="workUnitText.C">描述</@label></th>
                                                <th width="100"><@label key="workCenterCode.C">工作中心编号</@label></th>
                                            </tr>
                                        </thead>
                                        <tbody id="workUnitBody">
                                            <#if workUnits??> <#if (workUnits?size>0)><#list workUnits as workUnit>
                                            <tr id="workUnit_${workUnit.workUnitCode!''}" target="workUnit_workUnitCode" rel="${workUnit.workUnitCode!''}">
                                                <td width="16"><input type="checkbox" name="ids" class="checkboxCtrl" value="${workUnit.workUnitCode!''}">
                                                </td>
                                                <td width="100">${workUnit.workUnitCode!''}</td>
                                                <td width="100">${workUnit.workUnitText!''}</td>
                                                <td width="100">${workUnit.workCenterCode!''}</td>
                                            </tr>
                                            </#list><#else>
                                                <#if "read"==pattern>
                                                <tr>
                                                    <td colspan="4" class="noData">======<@label key='noListData.C'>列表无数据</@label>=====</font></td>
                                                </tr>
                                                </#if>
                                            </#if></#if>
                                        </tbody>
                                    </table>
                                </div>
                                </div>
                        </div>
                        
        
    
        <#if workUnitType??> 
            <#assign createInfo=workUnitType>
                <#include "/common/createInfo.html"> 
        </#if>
        <div class="formBar">
            <ul>
                <li>
                <#if "read"!=pattern>
                <div class="buttonActive" id="save">
                        <div class="buttonContent">
                            <button type="submit" onclick="check()"><@label key="save.B">保存</@label></button>
                        </div>
                    </div>
                </#if>
                    </li>
                        <li>
                    <#if "read"==pattern>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                    <@label key="close.B">关闭</@label>
                            </button>
                        </div>
                    </div>
                    <#else>
                    <div class="buttonActiveGrey">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                <@label key="cancel.B">取消</@label>
                            </button>
                        </div>
                    </div>
                    </#if>
                </li>
            </ul>
        </div>
</div>
</form>


    
<script type="text/javascript">

function check(){
    
        $('#workUnitBody input[name="ids"]').attr("checked", true);
    
}
function workUnit_callback() {
    var workUnitCode = $("#workUnitBar #workUnitCode").val();
    var workUnitText = $("#workUnitBar #workUnitText").val();
    var workCenterCode = $("#workUnitBar #workCenterCode").val();
    console.log("::"+workUnitCode);
    var idArr = new Array();
    var nameArr = new Array();
    var centerArr = new Array();
    idArr = workUnitCode.split(',');
    nameArr = workUnitText.split(',');
    centerArr = workCenterCode.split(',');
    var ht = "";
    for ( var i = 0; i < idArr.length; i++) {
        var id = idArr[i];
        var name = nameArr[i];
        var centerId = centerArr[i];
        var my_element = $("#workUnit_" + id);
        if (my_element.length == 0) {
            ht += "<tr id='workUnit_"+id+"'target='workUnit_workUnitCode' rel='"+id+"'><td width='20'><input  name='ids' value='"+id+"' type='checkbox'></td><td width='100'>"
                    + id
                    + "</td><td width='100'>"
                    + name
                    + "</td><td width='100'>"
                    + centerId
                    + "</td></tr>";
        }

    }
    $("#workUnitBody").append(ht);
    $.jTableTool.initGridColumnWidth($("#workUnitTypeTable"));

}

function workUnitdel() {
    var count = 0;
    $('input[name="ids"]:checked').each(function(i, e) {
        count++;
    });
    if (count == 0) {
        alertMsg.warn('<@label key="selectWorkUnit.M">请勾选作业单元！</@label>')
    } else {
        alertMsg.confirm("<@label key="delWorkUnit.M">确定要删除选中的作业单元吗？</@label>", {
            okCall : function() {
                $('input[name="ids"]:checked').each(function(i, e) {
                    $("#workUnit_" + e.value+'').remove();
                    $.jTableTool.initGridColumnWidth($("#workUnitTypeTable"));
                });
            }
        });
    }
}


</script>
